

package nameswap;
import java.util.Scanner;

public class NameSwap {

    public static void main(String[] args) {
        Scanner user_input = new Scanner(System.in);
        System.out.println("This system will swap your name!");
        System.out.println("Input your full name here; ");
        String FullName = user_input.nextLine();
        System.out.println(FullName);
        String subString1, subString2, resultString;
        int sep_index;
        subString1 = FullName.substring(0,2);
        sep_index = FullName.indexOf(" ");
        subString2 = FullName.substring((sep_index+1),(sep_index+3));
        resultString = subString2 + FullName.substring(2,sep_index+1)
                        + subString1 + FullName.substring(sep_index+3);
        System.out.println("Result string is :" + resultString);
        System.exit(0);
    }
    
}
